// pages/kefuwzh/kefuwzh.js
Page({
  data: {
    inputValue: "",
    chatRecord: [
      { type: "customer", content: "您好呀～准备开启怎样的奇妙旅行呢，都可以跟我说哟～" }
    ],
    isLoading: false
  },
  onClickLeft() {
    wx.navigateBack();
  },
  onInputChange(e) {
    this.setData({
      inputValue: e.detail.value
    });
  },
  onSendMessage() {
    if (!this.data.inputValue.trim()) {
      wx.showToast({
        title: "请输入内容",
        icon: "none",
        duration: 1500
      });
      return;
    }
    // 显示加载
    this.setData({ isLoading: true });
    // 模拟发送消息（实际替换为调用客服接口）
    const newMsg = { type: "mine", content: this.data.inputValue };
    let chatRecord = [...this.data.chatRecord, newMsg];
    this.setData({ chatRecord, inputValue: "" });
    
    // 模拟客服回复（实际应根据接口返回处理）
    setTimeout(() => {
      const replyMsg = { type: "customer", content: "您的问题已收到，会尽快为您解答～" };
      chatRecord = [...chatRecord, replyMsg];
      this.setData({ chatRecord, isLoading: false });
    }, 1500);
  }
});